const { GameModel } = require('../Model/GameModel');

let CellTypeNumber = 4; // 动物种类数

cc.Class({
    extends: cc.Component,

    properties: {
        setPanel: cc.Node,
        cellTypeNumber: cc.Label,
        grid: {
            type: cc.Node,
            default: null
        }
    },

    // use this for initialization
    onLoad: function () { },

    onStartGame() {
        CellTypeNumber = this.cellTypeNumber.string;
        this.setPanel.active = false;
        this.grid.active = true;
        this.gameModel = new GameModel();
        this.gameModel.init(CellTypeNumber);
        var gridScript = this.grid.getComponent("GridView");
        gridScript.setController(this);
        gridScript.initWithCellModels(this.gameModel.getCells());
    },

    selectCell: function (pos) {
        return this.gameModel.selectCell(pos);
    },

    cleanCmd: function () {
        this.gameModel.cleanCmd();
    },

});
